package com.octo.poker.data;

public enum CardValue {

	TWO(2, "2"),
	THREE(3, "3"),
	FOUR(4, "4"),
	FIVE(5, "5"),
	SIX(6, "6"),
	SEVEN(7, "7"),
	HEIGHT(8, "8"),
	NINE(9, "9"),
	TEN(10, "10"),
	JACK(11, "J"),
	QUEEN(12, "Q"),
	KING(13, "K"),
	ACE(14, "A");

	private Integer value;
	private String code;

	private CardValue(int value, String code) {
		this.value = value;
		this.code = code;
	}

	public Integer getValue() {
		return value;
	}

	@Override
	public String toString() {
		return code;
	}

	public static CardValue parse(String s) {
		for(CardValue cardValue : CardValue.values()) {
			if (cardValue.code.equals(s)) {
				return cardValue;
			}
		}
		return null;
	}

}
